package Data::Conveyor::Value::Ticket::Number;

# $Id: Number.pm 13447 2007-08-13 13:37:27Z gr $

use strict;
use warnings;
use Date::Calc qw/Today_and_Now Decode_Date_US/;


our $VERSION = '0.02';


use base 'Class::Value';


sub is_well_formed_value {
    my ($self, $value) = @_;
    $self->SUPER::is_well_formed_value($value) && $value =~ /^\d{12}\.\d{9}$/;
}


sub new_from_now {
    my $self = shift;
    $self->new(value =>
        sprintf('%04d%02d%02d%02d%02d.%09d', (Today_and_Now)[0..4], 0));
}


sub new_from_date {
    my ($self, $date) = @_;
    if ($date =~ /^\d{8}$/) {
        $date .= '0000.000000000'
    } else {
        $date = sprintf('%04d%02d%02d%02d%02d.%09d',
            Decode_Date_US($date), 0, 0, 0);
    }
    $self->new(value => $date);
}


1;


__END__

{% USE p = PodGenerated %}

=head1 NAME

{% p.package %} - stage-based conveyor-belt-like ticket handling system

=head1 SYNOPSIS

    {% p.package %}->new;

=head1 DESCRIPTION

None yet. This is an early release; fully functional, but undocumented. The
next release will have more documentation.

=head1 METHODS

=over 4

{% p.write_methods %}

=back

{% p.write_inheritance %}

{% PROCESS standard_pod %}

=cut

